package com.ssm.studen.service.impl;

import com.ssm.studen.dao.LoginlogDao;
import com.ssm.studen.model.Loginlog;
import com.ssm.studen.service.LoginlogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * 登录日志表：
 *          实现业务及流程接口当中的内容
 */
@Service
public class LoginlogServiceImpl implements LoginlogService {

    @Autowired
    private LoginlogDao loginlogDao;


    /**
     * 登录日志通过主键查询
     * @param lnum
     * @return
     */
    @Override
    public List<Loginlog> selectLoginlog(int lnum) {
       List<Loginlog> list = loginlogDao.selectLoginlog(lnum);
       return list;
    }


    /**
     * 登录日志添加
     * @param loginlog
     * @return
     */
    @Override
    public int insertLoginlog(Loginlog loginlog) {
        int result = 0;
        int loginlogCount = loginlogDao.loginlogCount(loginlog.getLnum());
        if(loginlogCount<1){
            int add = loginlogDao.insertLoginlog(loginlog);
            result = add;
        }else{
            result = -1;
        }
        return result;
    }
}










